package com.llyb.config;

import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.model.openai.OpenAiEmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.qdrant.QdrantEmbeddingStore;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LLMConfig {

    @Bean
    public EmbeddingModel embeddingModel(){
        return OpenAiEmbeddingModel.builder().
                apiKey(System.getenv("aliQwen-api")).
                modelName("text-embedding-v3").
                baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1").
                build();
    }

    @Bean
    public QdrantClient qdrantClient(){

        QdrantGrpcClient build = QdrantGrpcClient.
                newBuilder("192.168.6.100", 6334, false).
                build();

        return new QdrantClient(build);
    }

    @Bean
    public EmbeddingStore<TextSegment> embeddingStore(){
        return QdrantEmbeddingStore.builder().
                host("192.168.6.100").
                port(6334).
                collectionName("test-qdrant").
                build();
    }



}